<!-- 用户中心侧边栏 -->
<div class="lg:col-span-1">
    <div class="bg-blue-50 rounded-sm p-6 ">
        <!-- 用户信息 -->
        <div class="text-center mb-6 pb-6 border-b border-gray-200">
            <div class="w-16 h-16 bg-blue-500 rounded-full flex items-center justify-center mx-auto mb-3">
                <i class="fas fa-user text-white text-xl"></i>
            </div>
            <h3 class="font-semibold text-gray-800" id="sidebar-username">用户</h3>
            <p class="text-sm text-gray-500" id="sidebar-email"></p>
        </div>

        <!-- 导航菜单 -->
        <nav class="space-y-2">
            <a href="{:_url_('user.index')}"
                class="flex items-center px-3 py-2 rounded-sm {if $current_page == 'index'}bg-blue-50 text-blue-600{else}text-gray-500 hover:bg-gray-100 hover:text-blue-600{/if} transition-colors">
                <i class="fas fa-home mr-3"></i>
                <span>用户中心</span>
            </a>
            <a href="{:_url_('user.order')}"
                class="flex items-center px-3 py-2 rounded-sm {if $current_page == 'order'}bg-blue-50 text-blue-600{else}text-gray-500 hover:bg-gray-100 hover:text-blue-600{/if} transition-colors">
                <i class="fas fa-shopping-bag mr-3"></i>
                <span>我的订单</span>
            </a>
            <a href="{:_url_('user.favorite')}"
                class="flex items-center px-3 py-2 rounded-sm {if $current_page == 'favorite'}bg-blue-50 text-blue-600{else}text-gray-500 hover:bg-gray-100 hover:text-blue-600{/if} transition-colors">
                <i class="fas fa-heart mr-3"></i>
                <span>我的收藏</span>
            </a>
            <a href="{:_url_('user.level')}"
                class="flex items-center px-3 py-2 rounded-sm {if $current_page == 'level'}bg-blue-50 text-blue-600{else}text-gray-500 hover:bg-gray-100 hover:text-blue-600{/if} transition-colors">
                <i class="fas fa-crown mr-3"></i>
                <span>会员等级</span>
            </a>
            <a href="{:_url_('user.vip')}"
                class="flex items-center px-3 py-2 rounded-sm {if $current_page == 'vip'}bg-blue-50 text-blue-600{else}text-gray-500 hover:bg-gray-100 hover:text-blue-600{/if} transition-colors">
                <i class="fas fa-gem mr-3"></i>
                <span>VIP会员</span>
            </a>
            <a href="{:_url_('user.sign')}"
                class="flex items-center px-3 py-2 rounded-sm {if $current_page == 'sign'}bg-blue-50 text-blue-600{else}text-gray-500 hover:bg-gray-100 hover:text-blue-600{/if} transition-colors">
                <i class="fas fa-calendar-check mr-3"></i>
                <span>每日签到</span>
            </a>
        </nav>
    </div>
</div>

<script>
    // 动态更新侧边栏用户信息
    function updateSidebarUserInfo() {
        // 检查登录状态（基于cookie）
        if (window.userState && window.userState.isLogin && window.userState.userInfo) {
            const userInfo = window.userState.userInfo;
            $('#sidebar-username').text(userInfo.username || '用户');
            $('#sidebar-email').text(userInfo.email || '');
        } else {
            // 未登录，使用默认值
            $('#sidebar-username').text('用户');
            $('#sidebar-email').text('');
        }
    }

    // 页面加载时更新用户信息
    $(document).ready(function () {
        updateSidebarUserInfo();

        // 监听用户状态变化
        $(document).on('userStateUpdated', function () {
            updateSidebarUserInfo();
        });
    });
</script>